﻿@model IEnumerable<JunFan.ViewModels.ItemView>

@{
    var avgLeadTime = Model.Count() > 0 ? Model.Average(x => x.LeadTime) : 0;
}

<h2>Completed items</h2>
<h3>Average lead time: @avgLeadTime </h3>

<table id="completedItems">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Id)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Description)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.CreatedOn)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.CompletedOn)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.LeadTime)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Id)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Description)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.CreatedOn)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.CompletedOn)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.LeadTime)
        </td>
    </tr>
}
</table>